{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pandas.tools.plotting import scatter_matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def TEGetData(country, indicator):\n",
    "    if isinstance(country, list):\n",
    "        myCountries = ','.join(country)       \n",
    "    else:\n",
    "        myCountries = country    \n",
    "        \n",
    "    if isinstance(indicator, list):\n",
    "        myIndicators =  ','.join(indicator) \n",
    "    else:\n",
    "        myIndicators = indicator\n",
    "        \n",
    "    url = 'https://api.tradingeconomics.com/historical/country/{cntry}/indicator/{ind}/?client=guest:guest'.format(cntry=myCountries,ind=myIndicators)\n",
    "    url = url.replace(' ', '%20')\n",
    "    json = pd.read_json(url)\n",
    "    return json"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
